package com.ppc.controller.employer;


import com.ppc.dto.EmployerRequireModifyDTO;
import com.ppc.dto.EmployerRequirePageQueryDTO;
import com.ppc.dto.EmployerRequirementDTO;
import com.ppc.result.PageResult;
import com.ppc.result.Result;
import com.ppc.service.EmployerRequireService;
import com.ppc.vo.EmployerRequireDetailVO;
import com.ppc.vo.EmployerTagVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 雇主需求相关接口
 *
 * @author LENOVO
 * @date 2023/12/20
 */
@RestController
@RequestMapping("/employer/requirement")
@Slf4j

@Api(tags = "雇主需求相关接口")
public class EmployerRequirementController {

  @Autowired
  private EmployerRequireService employerRequireService;

  /**
   * 雇主创建需求
   *
   * @param employerRequirementDTO
   * @return
   */
  @PostMapping
  @ApiOperation("雇主创建需求")
  public Result createRequirement(@RequestBody EmployerRequirementDTO employerRequirementDTO) {
    log.info("雇主创建需求：{}", employerRequirementDTO);
    employerRequireService.createRequirement(employerRequirementDTO);
    return Result.success();
  }


  /**
   * 雇主修改需求
   *
   * @param employerRequireModifyDTO
   * @return
   */
  @PutMapping
  @ApiOperation("雇主修改需求")
  public Result updateRequirement(@RequestBody EmployerRequireModifyDTO employerRequireModifyDTO) {
    log.info("雇主修改需求：参数为：{}", employerRequireModifyDTO);
    employerRequireService.updateRequirement(employerRequireModifyDTO);
    return Result.success();
  }


  /**
   * @param requireId
   * @param requireStatus
   * @return {@link Result }
   * @description
   */
  @DeleteMapping
  @ApiOperation("雇主删除需求")
  public Result deleteRequire(Long requireId) {

    log.info("雇主删除需求：参数为：{}", requireId);
    employerRequireService.requireDel(requireId);
    return Result.success();
  }
  /**
   * 雇主查看需求详细信息
   * @param requireId
   * @return
   */
  @GetMapping("/detail")
  @ApiOperation("雇主查看需求详细信息")
  public Result<EmployerRequireDetailVO> detailRequirement(Long requireId) {
    log.info("雇主查看需求详细信息：参数为：{}", requireId);
    EmployerRequireDetailVO employerRequireDetailVO = employerRequireService.checkRequireDetail(requireId);
    return Result.success(employerRequireDetailVO);
  }

  /**
   * 雇主分页查询需求
   *
   * @param employerRequirePageQueryDTO
   * @return
   */
  @GetMapping("/page")
  @ApiOperation("雇主分页查询需求")
  public Result<PageResult> pageQuery(EmployerRequirePageQueryDTO employerRequirePageQueryDTO) {
    log.info("雇主分页查询需求，参数为：{}", employerRequirePageQueryDTO);
    PageResult pageResult;
    pageResult = employerRequireService.pageQuery(employerRequirePageQueryDTO);
    return Result.success(pageResult);
  }

  /**
   * 雇主查看全部标签
   *
   * @return
   */
  @GetMapping("/tag")
  @ApiOperation("雇主查看全部标签")
  public Result<List> tagCheck() {
    log.info("雇主查看全部标签");
    List<EmployerTagVO> tag = employerRequireService.checkTag();
    return Result.success(tag);
  }


}
